<%@ page contentType="text/html;charset=UTF-8" %>
<div class="admin-main">
    <div id="college">
        <fieldset class="layui-elem-field">
            <legend>创建学院</legend>
            <div class="layui-field-box">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">大学：</label>
                            <div class="layui-input-inline">
                                <select name="universityid" lay-verify="chooseUniversity" id="showUniversity"
                                        lay-search>
                                    <option value="">请选择大学</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">学院名称：</label>
                            <div class="layui-input-inline" style="width: 200px">
                                <input name="name" placeholder="请输入学院名称" lay-verify="required" class="layui-input"
                                       autocomplete="off">
                            </div>
                            <div class="layui-input-inline">
                                <button lay-filter="createCollege" class="layui-btn" lay-submit>创建</button>
                            </div>
                        </div>

                    </div>
                </form>
            </div>
        </fieldset>
    </div>
</div>
<script>
    "use strict";
    layui.use(['form', 'layer', 'jquery'], function () {
        var form = layui.form(),
            $ = layui.jquery;
        axios.get("/university/findAll")
            .then(function (response) {
                var array = response.data.data;
                var html = '';
                for (var i in array) {
                    html += '<option value=' + array[i].id + '>' + array[i].name + '</option>';
                }
                $('#showUniversity').append(html);
                form.render('select');
            })
            .catch(function (response) {
                console.log(response);
            })
    })
</script>
